
<header class="layout head padding-small">
    <a href="javascript:back(true);" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white"><?php echo $output['gc_name']?></h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>
<div class="margin">
    <div class="layout">
        <div class="line">
            <ul class="x12 list-unstyle">
                    <li class="x9"><input type="text" id="goods_keyword" value="<?php echo
                        $_GET['keyword']?>" class="input left_yj" placeholder="输入商品名称"></li>
                    <li class="x3"><input type="button" onclick="submit_keywords()" class="button right_yj bg-dot button-block" value="搜 索"/></li>
            </ul>
        </div><!--//line-->
    </div>
</div>
<div class="layout padding-small-top"><!--header 导航-->
    <div class="container">
        <div class="tab bg-white radius-big padding-small text-center">
            <div class="tab-head">
                <ul class="tab-nav">
                    <li class="active"><a href="#tab-start">排序</a></li>
                    <li><a href="#tab-css">发货方</a></li>
                    <li><a href="#tab-unit" class="dialogs" data-toggle="click" data-target="#mydialog" data-mask="1" data-width="90%">规格<span class="icon-caret-down padding-small-left"></span></a>
                        <div id="mydialog">
                            <div class="dialog">
                                <?php if(!empty($output['attr_array']) && is_array($output['attr_array'])){?>
                                <div id="attr_list" class="dialog-body clearfix text-little guige-list"><!--弹出框显示的内容-->
                                    <?php
                                    $check_spec = explode(',',$_GET['a_id']);
                                    foreach ($output['attr_array'] as $key=>$val){
                                    $id_arr = array_keys($val['value']);
                                    $state = false;
                                    foreach($id_arr as $id){
                                        if(in_array($id,$check_spec)){
                                            $state = true;
                                            break;
                                        }
                                    }
                                    ?>
                                    <p class="qcwbj"><a href="javascript:void(0)"><?php echo $val['name'];?></a></p>
                                    <ul  class="x12 border-bottom padding-small-top padding-small-bottom list-unstyle text-center bg">
                                        <li class="float-left padding-small <?php if(!$state) echo 'on';?>" onclick="selectExpandSort(this)"  data="0"><input name="gg<?php echo $val['name'];?>" <?php if(!$state) echo 'checked="checked"';?> type="radio">全部</li>
                                        <?php
                                        if(!empty($val['value']) && is_array($val['value'])){
                                        foreach ($val['value'] as $k=>$v){
                                        ?>
                                        <li class="float-left padding-small <?php if(in_array($k,$check_spec)) echo 'on';?>" onclick="selectExpandSort(this)" data="<?php echo $k;?>"><input name="gg<?php echo $val['name'];?>" type="radio"  <?php if(in_array($k,$check_spec)) echo 'checked="checked"';?> ><?php echo $v['name'];?></li>
                                        <?php }?>
                                        <?php }?>

                                    </ul>
                                    <?php }?>
                                </div><!--//弹出框显示的内容-->
                                <?php }else{?>
                                    <div class="dialog-body clearfix text-little">
                                        <p>暂无数据</p>
                                    </div>
                                <?php }?>
                                <div class="dialog-foot" style="border-top:none;">
                                    <button class="button button-small dialog-close">取消</button>
                                </div>
                                <style>
                                    /*规格卡样式设置：位置以及超出高度出现滚动条*/
                                    .dialog-win{top:50px !important;}
                                    .dialog-win ul{max-height:100px;overflow: auto !important;}
                                </style>
                                <script>
                                    $(document).ready(function()
                                    {    //规格卡卷帘效果
                                       // alert($(".guige-list").length)
                                        $(".guige-list:eq(1) ul:gt(0)").hide();
                                        $(".dialog-body p").click(function()
                                        {
                                            $(this).siblings('ul').slideUp();
                                            $(this).next("ul").slideDown();

                                        });
                                    });
                                </script>
                            </div>
                        </div>

                    </li>
                    <li><a href="#tab-units"><em class="<?php switch($_GET['type']){
                                case 1:
                                   echo 'doublerow-icon';
                                    break;
                                case 2:
                                    echo 'single-icon';
                                    break;
                                case 3:
                                    echo  'large-icon';
                                    break;
                                default:
                                    echo  'doublerow-icon';
                            };?>">&nbsp;</em></a></li>
                </ul>
            </div>
            <div class="tab-body radius-big">
                <div class="tab-panel active" id="tab-start">
                    <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="default" class="padding-left padding-right <?php if($_GET['key']=='default' || $_GET['key'] == ''){ echo 'text-red';}?>">默认</a>
                    <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="sales" class="padding-left padding-right <?php if($_GET['key']=='sales'){echo 'text-red';}?>">销量<?php echo ($_GET['order']=='desc' && $_GET['key']=='sales')?'↑':(($_GET['order']=='asc' && $_GET['key']=='sales')?'↓':'')?></a>
                    <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="price" class="padding-left padding-right <?php if($_GET['key']=='price'){echo 'text-red';}?>">价格<?php echo ($_GET['order']=='desc' && $_GET['key']=='price')?'↑':(($_GET['order']=='asc' && $_GET['key']=='price')?'↓':'')?></a>
                    <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="credit"  class="padding-left padding-right <?php if($_GET['key']=='credit'){ echo 'text-red';}?>">信用<?php echo ($_GET['order']=='desc' && $_GET['key']=='credit')?'↑':(($_GET['order']=='asc' && $_GET['key']=='credit')?'↓':'')?></a>
                    <a href="javascript:void(0)" onclick="changeOrder(this)" data-tp="click" class="padding-left padding-right <?php if($_GET['key']=='click'){ echo 'text-red';}?>">人气<?php echo ($_GET['order']=='desc' && $_GET['key']=='click')?'↑':(($_GET['order']=='asc' && $_GET['key']=='click')?'↓':'')?></a>
                </div>

                <div class="tab-panel" id="tab-css">
                    <a href="javascript:void(0)" id="self_all" class="padding-left padding-right"><input name="dxan" type="radio" id="mr" value="" <?php echo !(int)$_GET['store'] > 0 ?'checked':''?> ><label for="mr">默认</label></a>
                    <a href="javascript:void(0)" id="self_jd"  class="padding-left padding-right"><input name="dxan" type="radio" id="mcgw" value="" <?php echo (int)$_GET['store'] > 0 ?'checked':''?>><label for="mcgw">美财官方</label></a>
                </div>

                <div class="tab-panel" id="tab-units">
                    <a  href="javascript:void(0)" onclick="showType(this)" data-tn='1' class="padding-left padding-right <?php echo $_GET['type']==1 || !isset($_GET['type']) ? 'zt_color':'';?>">两列显示</a>
                    <a  href="javascript:void(0)" onclick="showType(this)" data-tn='2' class="padding-left padding-right <?php echo $_GET['type']==2 ? 'zt_color':'';?>">单列显示</a>
                    <a  href="javascript:void(0)" onclick="showType(this)" data-tn='3' class="padding-left padding-right <?php echo $_GET['type']==3 ? 'zt_color':'';?>">大图显示</a>
                </div>
            </div>
        </div>
    </div>
</div><!--//header 导航-->

<?php require_once 'goods_list_'.$output['display_mode'].'.php';?>
<?php require_once 'page.php';?>

<form id="condtion" method="get">
    <input type="hidden" name="act" value="search" />
    <input name="cate_id" value="<?php echo (int)$_GET['cate_id']?>" type="hidden">
    <input name="keyword" value="<?php echo trim($_GET['keyword'])?>" type="hidden" />
    <input name="type" value="<?php echo (int)$_GET['type']?>" type="hidden" />
    <input name="key" value="<?php echo $_GET['key'];?>" type="hidden" />
    <input name="order" value="<?php echo $_GET['order'];?>" type="hidden" />
    <input name="a_id" id="a_id" value="<?php echo $_GET['a_id']?>" type="hidden">
    <input name="store" value="<?php echo $_GET['store']?>" type="hidden" />
</form>
<script>
    $(document).ready(function()
    {

        //发货方 默认 点击事件
        $('#self_all').click(function(){
            $('input[name=store]').val("0");
            pclicked('index.php?'+$('#condtion').serialize());
        });
        //发货方 美财官方 点击事件
        $('#self_jd').click(function(){
            $('input[name=store]').val("1");
            pclicked('index.php?'+$('#condtion').serialize());
        });
    });
    //搜索事件
    function submit_keywords(){
        var goods_keyword = $('#goods_keyword').val();
        var input_keywords= $('input[name=keyword]');
        input_keywords.val(goods_keyword);
        pclicked('index.php?'+$('#condtion').serialize());
    }
    //选择规格值的事件 绑定在li上的
    function selectExpandSort(obj){
        $(obj).addClass('on').siblings('li').removeClass('on');
        $(obj).children('input').attr('checked',true);
        var div = $('.guige-list:eq(1)').find('li.on');
        var esId = '';
        for(var i=0,len=div.size();i<len;i++){
            if(parseInt($(div[i]).attr('data')) != 0){
                if(esId != '') esId+=',';
                esId+=$(div[i]).attr('data');
            }
        }
        $('#a_id').val(esId);
        pclicked('index.php?'+$('#condtion').serialize());
    }

    function changeOrder(obj){
        var key = $('input[name=key]');
        var order = $('input[name=order]');
        if($(obj).data('tp') == key.val()){
            if($(obj).data('tp') == 'default'){
                order.val('');
            }else if(order.val() == 'desc'){
                order.val('asc');
            }else {
                order.val('desc');
            }
        }else{
            key.val($(obj).data('tp'));

            if($(obj).data('tp') == 'default'){
                order.val('');
            }else{
                order.val('desc');
            }
        }
        pclicked('index.php?'+$('#condtion').serialize());
    }
    //点击列表显示方式事件
    function showType(obj){
        $('input[name=type]').val($(obj).data('tn'));
        pclicked('index.php?'+$('#condtion').serialize());
    }

</script>